import React from 'react';
import {connect} from 'react-redux';
import {Card} from 'antd-mobile';
import {userListAxios} from '../../redux/userListInfo';

class Genius extends React.Component {
    componentDidMount() {
        this.props.userListAxios('boss');
    };
    render() {
        // console.log(this.props);
        return (
            <div>
                {this.props.desc?<p>{this.props.desc}</p>:null}
                {this.props.bossList.map((item,index) => (
                    <Card 
                        full={false} 
                        key={item._id}
                        onClick={this.chatWith.bind(this,item._id)}
                    >
                        <Card.Header
                            title={item.company}
                            thumb={require(`../../component/img/${item.avatarText}.png`)}
                            extra={<span>{item.joinPosition}</span>}
                        />
                        <Card.Body>
                            <div>{item.desc}</div>
                        </Card.Body>
                        <Card.Footer content={item.money} extra={<div>{item.xueli}</div>} />
                    </Card>
                ))}
                
            </div>
        )
    }
    chatWith = (id) => {
        // console.log(id);
        // 点击信息携带id跳转到聊天页面
        this.props.history.push(`/chat/${id}`);
    }
}

const mapStateToProps = (state) => {
    return{
        bossList:state.userList.userListArr,
        desc:state.userList.desc,
        user:state.registerReducer
    }
}
const mapDispatchToProps = {userListAxios};
export default connect(mapStateToProps,mapDispatchToProps)(Genius);